<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" style="height: 100%">
<head>
    <th:block th:fragment="common_head">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title th:text="${webName}"></title>
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="stylesheet" th:href="@{/css/font.css}">
        <link rel="stylesheet" th:href="@{/css/iconfont.css}">
        <link rel="stylesheet" th:href="@{/layui/css/layui.css?t=2402}">
        <link rel="stylesheet" th:href="@{/css/index.css?t=2105}">
    </th:block>
</head>
<body>
    <th:block th:fragment="common_jsfiles">
        <!-- 引用JavaScript文件 -->
        <script type="text/javascript" th:src="@{/jsfiles/jQuery.min.js?t=1}"></script>
        <script type="text/javascript" th:src="@{/layui/layui.js?t=2402}" charset="utf-8"></script>
        <script type="text/javascript" th:src="@{/jsfiles/crypto-js.min.js?t=1}" charset="utf-8"></script>
        <script type="text/javascript" th:src="@{/jsfiles/com.js?t=2132201121}" charset="utf-8"></script>
        <script type="text/javascript" th:src="@{/jsfiles/index.js?t=20813}" charset="utf-8"></script>
    </th:block>
    <!--    校验是否登录，不写库的页面引入这个，写库的引入下一个  -->
    <th:block th:fragment="check_login">
        <script>
            $(document).ready(function() {
                $.ajax({
                    type:"post",
                    url:"[[${serverUrl}]]/check_login",
                    dataType:"json",
                    timeout : 10*1000, //超时时间设置，单位毫秒
                    crossDomain: true,
                    contentType: 'application/json;charset=UTF-8',
                    headers: {
                        "token": localStorage.getItem("token") // 在请求头中添加token
                    },
                    beforeSend: function(request) {
                        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                    },
                    success:function(result){
                        if (result.code==6) parent.parent.parent.window.location.href="../../../../../../admin/login";
                    },
                    error:function(result){
                        if (result.code==6) parent.parent.parent.window.location.href="../../../../../../admin/login";
                    }
                });
            });
        </script>
    </th:block>
    <!--    校验登录的时候，获取操作令牌，避免重复操作和阻止重放攻击。写库的页面都需要引入！  -->
    <th:block th:fragment="getnonce(ms)">
        <input type="hidden" id="nonce_ms" name="nonce_ms" th:value="${ms}">
        <input type="hidden" id="nonce_zhi" name="nonce_zhi">
        <script>
            var ms = $("#nonce_ms").val();
            var a = {
                ms: ms,
                timestamp:new Date().getTime()
            };
            var b = {
                data:encrypt_str(JSON.stringify(a),localStorage.getItem("a"),localStorage.getItem("b"))
            };
            $(document).ready(function() {
                $.ajax({
                    type:"post",
                    url:"[[${serverUrl}]]/getnonce",
                    data:JSON.stringify(b),
                    dataType:"json",
                    timeout : 10*1000, //超时时间设置，单位毫秒
                    crossDomain: true,
                    contentType: 'application/json;charset=UTF-8',
                    headers: {
                        "token": localStorage.getItem("token") // 在请求头中添加token
                    },
                    beforeSend: function(request) {
                        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                    },
                    success:function(result){
                        if (result.code==6) parent.parent.parent.window.location.href="../../../../../../admin/login";
                        let rtn = decrypt_str(result.data,localStorage.getItem("a"),localStorage.getItem("b"));
                        $("#nonce_zhi").val(rtn);
                    },
                    error:function(result){
                        if (result.code==6) parent.parent.parent.window.location.href="../../../../../../admin/login";
                    }
                });
            });
        </script>
    </th:block>
</body>
</html>